import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    history:[]
  },
  mutations: {
    ADD_HISTORY(state,item){
      var index = state.history.findIndex((ele)=>{
        return ele === item
      })
      if(index != -1){
        state.history.splice(index,1)
      }
      state.history.unshift(item)
    }
  },
  actions: {
    ADD_HISTORY(context,item){
      context.commit('ADD_HISTORY',item)
    }
  },
  modules: {
  }
})
